package com.originskyseed.platform.user.controller;

import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang3.StringUtils;
import org.apache.dubbo.config.annotation.DubboReference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.util.DigestUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.bingoohuang.patchca.service.Captcha;
import com.originskyseed.platform.common.annotation.SysLog;
import com.originskyseed.platform.common.api.config.LoginConfig;
import com.originskyseed.platform.common.api.config.SMSConfig;
import com.originskyseed.platform.common.api.constant.WebappKeyConstants;
import com.originskyseed.platform.common.api.util.smsUtil;
import com.originskyseed.platform.core.aspect.annotation.RequiredParams;
import com.originskyseed.platform.core.base.BaseController;
import com.originskyseed.platform.core.base.BaseLocaleResource;
import com.originskyseed.platform.core.base.BaseResponseBody;
import com.originskyseed.platform.core.common.code.CommonResponseCode;
import com.originskyseed.platform.core.config.bean.ConfigManager;
import com.originskyseed.platform.core.filter.helper.SingleSignOnTokenHelper;
import com.originskyseed.platform.core.filter.util.FilterCacheUtil;
import com.originskyseed.platform.core.filter.util.FilterSystemTypeUtil;
import com.originskyseed.platform.core.redis.util.RedisUtil;
import com.originskyseed.platform.core.util.bean.AccessObjectUtil;
import com.originskyseed.platform.core.util.bean.ImageCodeUtil;
import com.originskyseed.platform.role.model.Menu;
import com.originskyseed.platform.role.model.Role;
import com.originskyseed.platform.role.service.IMenuService;
import com.originskyseed.platform.role.service.IRoleService;
import com.originskyseed.platform.user.i18n.RegisterResponseMsg;
import com.originskyseed.platform.user.i18n.UserResponseMsg;
import com.originskyseed.platform.user.model.TradeUnion;
import com.originskyseed.platform.user.model.UserInfo;
import com.originskyseed.platform.user.service.ITradeUnionService;
import com.originskyseed.platform.user.service.IUserInfoService;
import com.originskyseed.platform.user.vo.request.VerificationResponseVO;
import com.originskyseed.platform.user.vo.request.VerifyRequestVo;

/**
 * 登录Controller类
 *
 * @author HuangJianZhi
 */
@Controller
@RequestMapping("/register")
@BaseLocaleResource(localeFileName = "i18n_user")
public class RegisterController extends BaseController {

	private static final Logger logger = LoggerFactory.getLogger(RegisterController.class);

	@DubboReference
	private IUserInfoService userInfoService;

	@DubboReference
	private ITradeUnionService tradeUnionService;

	@DubboReference
	private IRoleService roleService;

	@DubboReference
	private IMenuService menuService;

	/**
	 * 注册帐号
	 *
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/register.json")
	@RequiredParams(names = { "account", "password", "name", "qq", "phone", "code" })
	@SysLog(module = "用户模块", operationDesc = "注册用户")
	public BaseResponseBody verification(HttpServletRequest request) {
		BaseResponseBody result = null;
		try {
			// 获取请求对象
			VerifyRequestVo requestVo = this.getParameterBean(VerifyRequestVo.class);

			// 请求对象
			TradeUnion tradeUnion = this.getParameterBean(TradeUnion.class);

			// 判断账号是否符合规则
			if (!requestVo.getAccount().matches("^[0-9A-Za-z]{16}$")) {
				return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_RULE_ERROR.getMsg()), false);
			}
			// 判断账号是否存在
			if (userInfoService.existAccount(requestVo.getAccount())) {
				return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_EXIST.getMsg()), false);
			}

			// 判断密码
			if (requestVo.getPassword().length() < 8) {
				return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.PASSWORD_LENGTH_ERROR.getMsg()), false);
			} else if (!requestVo.getPassword().matches("^(?=.*[0-9])(?=.*[a-zA-Z])[0-9A-Za-z!@#$%^&*,\\.]{8,64}$")) {
				return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.PASSWORD_SIMPLE_ERROR.getMsg()), false);
			} else if (!requestVo.getPassword().equals(requestVo.getConfirmPassword())) {
				return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.PASSWORD_INCONSISTENT.getMsg()), false);
			}

			// 判断公会名称
			if (!requestVo.getName().matches("^[A-Za-z0-9\u4e00-\u9fa5]+$")) {
				return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.NAME_ERROR.getMsg()), false);
			}

			// 判断qq
			if (!requestVo.getPassword().matches("^[0-9]{5,15}$")) {
				return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.QQ_ERROR.getMsg()), false);
			}

			// 判断验证码
			if (StringUtils.endsWithIgnoreCase(requestVo.getCode(), (String) RedisUtil.getInstance().getForObject(WebappKeyConstants.SMS_CODE_KEY + requestVo.getPhone()))) {
				// 判断手机号是否存在
				if (this.userInfoService.existMobileNumber(requestVo.getPhone())) {
					return new BaseResponseBody(true, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.REGISTER_EXIST.getMsg()), false);
				}
				UserInfo userInfo = new UserInfo();
				userInfo.setAccount(requestVo.getAccount());
				userInfo.setName(requestVo.getName());
				userInfo.setPassword(DigestUtils.md5DigestAsHex(requestVo.getPassword().getBytes()));
				userInfo.setPhone(requestVo.getPhone());
				userInfo.setStatus(0);
				userInfo.setIsDel(0);
				this.userInfoService.insertSelective(userInfo);
				tradeUnion.setAuditStatus(0);
				tradeUnion.setUserId(userInfo.getId());
				this.tradeUnionService.insertSelective(tradeUnion);
				return new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.REGISTER_VERIFICATION_SUCCESS.getMsg()), true);
			} else {
				result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.REGISTER_CODE_ERROR.getMsg()), false);
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.REGISTER_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 保存信息
	 *
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/tradeUnionSave.json", method = RequestMethod.POST)
	@RequiredParams(names = { "idCardNum", "idCardPic", "idCardBackpic", "idCardHold", "bankName", "bankAccount", "bank", "province", "branch" })
	public BaseResponseBody<TradeUnion> tradeUnionSave(HttpServletRequest request) {
		BaseResponseBody<TradeUnion> result = null;
		try {
			// 当前用户
			UserInfo userInfo = SingleSignOnTokenHelper.getCurrentUserInfo(UserInfo.class);
			// 请求对象
			TradeUnion tradeUnion = this.getParameterBean(TradeUnion.class);
			tradeUnion.setAuditStatus(0);
			tradeUnion.setUserId(userInfo.getId());
			if (StringUtils.isNotBlank(tradeUnion.getId())) {
				this.tradeUnionService.updateByPrimaryKey(tradeUnion);
			} else {
				this.tradeUnionService.insertSelective(tradeUnion);
			}
			result = new BaseResponseBody<TradeUnion>(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), UserResponseMsg.DATA_SAVE_SUCCESS.getMsg()), tradeUnion);
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody<TradeUnion>(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), UserResponseMsg.DATA_SAVE_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 注册时通过手机获取验证码
	 *
	 * @param request
	 * @param response
	 */
	@ResponseBody
	@RequestMapping(value = "/getRegisterCode.json")
	@RequiredParams(names = { "phone" })
	public BaseResponseBody getRegisterCode(HttpServletRequest request, HttpServletResponse response) {
		BaseResponseBody result = null;
		try {
			;
			// 获取手机号
			String phone = this.getParameterString("phone", null);
			// 生成验证码
			Captcha captcha = ImageCodeUtil.getCaptcha();
			// 验证手机号格式
			if (phone.matches("^1(3|4|5|6|7|8|9)\\d{9}$")) {
				// 判断手机号是否存在
				if (this.userInfoService.existMobileNumber(phone)) {
					return new BaseResponseBody(true, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.REGISTER_EXIST.getMsg()), false);
				}
				// 发送验证码
				String smsContent = null; // smsConfig.getSmsRegisterTemplate().replaceAll("\\{\\{code\\}\\}", captcha.getChallenge());
				String s = ""; // MessageUtils.sendMessage(phone, smsContent);
				if (StringUtils.isNotEmpty(s)) {
					RedisUtil.getInstance().setForObject(WebappKeyConstants.SMS_CODE_KEY + phone, captcha.getChallenge(), 60000L);
					result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_SUCCESS.getMsg()), true);
				} else {
					result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_ERROR.getMsg()), null);
				}
			} else {
				result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.PHONE_ERROR.getMsg()), null);
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 忘记密码
	 * 
	 * @param request
	 * @param response
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value = "/getForgetPasswordCode.json")
	@RequiredParams(names = { "phone", "account" })
	public BaseResponseBody getForgetPasswordCode(HttpServletRequest request, HttpServletResponse response) {
		BaseResponseBody result = null;
		try {
			SMSConfig smsConfig = ConfigManager.getInstance().parseObject(SMSConfig.class);
			// 获取手机号
			String phone = this.getParameterString("phone", null);
			// 账号
			String account = this.getParameterString("account", null);
			// 生成验证码
			Captcha captcha = ImageCodeUtil.getCaptcha();

			// 手机号验证码
			if (StringUtils.isNotBlank(phone)) {
				// 短信验证码
				if (phone.matches("^1(3|4|5|6|7|8|9)\\d{9}$")) {
					UserInfo userInfo = this.userInfoService.selectByAccount(account);
					// UserInfo userInfo = this.userInfoService.selectByPhoneNum(phone);
					// 判定手机号是否注册
					if (userInfo == null || !phone.equals(userInfo.getPhone())) {
						return new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_PHONE_ERROR.getMsg()), false);
					}
					String code = captcha.getChallenge();

					String[] phoneNumberSet = { "+86" + phone };
					String[] templateParamSet = { code, "60" };
					String s = smsUtil.sendSms(smsConfig.getSecretId(), smsConfig.getSecretKey(), smsConfig.getSdkAppId(), smsConfig.getSignName(), smsConfig.getTemPlateId(), phoneNumberSet, templateParamSet);
					request.getSession().setAttribute(WebappKeyConstants.SMS_CODE_KEY + phone + account, code);
					result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_SUCCESS.getMsg()), true);
				} else {
					result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_ERROR.getMsg()), null);
				}
			}
			// 图形验证码
			else {
				request.getSession().setAttribute(WebappKeyConstants.IMAGE_CODE_KEY, captcha.getChallenge());
				ImageCodeUtil.writeImage(captcha, response);
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 账号验证（忘记密码）
	 *
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/verificationAccount.json")
	@RequiredParams(names = { "phone", "code", "account" })
	public BaseResponseBody verificationAccount(HttpServletRequest request) {
		BaseResponseBody result = null;
		try {
			String phone = this.getParameterString("phone", null);
			String account = this.getParameterString("account", null);
			String code = this.getParameterString("code", null);
			// 验证码判定
			if (StringUtils.endsWithIgnoreCase(code, (String) request.getSession().getAttribute(WebappKeyConstants.SMS_CODE_KEY + phone + account))) {
				UserInfo userInfo = this.userInfoService.selectByAccount(account);
				if (userInfo != null) {
					request.getSession().setAttribute(WebappKeyConstants.UPDATE_PASSWORD_USER_ACCOUNT_KEY, userInfo.getAccount());
					request.getSession().setAttribute(WebappKeyConstants.USER_NAME_KEY, userInfo.getAccount());
					result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_SUCCESS.getMsg()), userInfo.getPhone());
				} else {
					result = new BaseResponseBody(true, CommonResponseCode.FAILURE_AUTHENTICATION.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_ERROR.getMsg()), false);
				}
			} else {
				result = new BaseResponseBody(true, CommonResponseCode.FAILURE_AUTHENTICATION.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_ERROR.getMsg()), false);
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 设置新密码（忘记密码）
	 *
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/updatePassword.json")
	@RequiredParams(names = { "password" })
	@SysLog(module = "用户模块", operationDesc = "设置用户新密码")
	public BaseResponseBody forgetPwd(HttpServletRequest request) {
		BaseResponseBody result = null;
		try {
			String password = this.getParameterString("password", null);
			// 拿到session中保存的账号
			String account = (String) request.getSession().getAttribute(WebappKeyConstants.UPDATE_PASSWORD_USER_ACCOUNT_KEY);

			if (StringUtils.isNotBlank(account)) {
				UserInfo userInfo1 = this.userInfoService.selectByAccount(account);
				String newPassword = DigestUtils.md5DigestAsHex(password.getBytes());
				if (newPassword.equals(userInfo1.getPassword())) {
					result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.NEW_OLD_PASSWORD_INCONFORMITY_ERROR.getMsg()), false);
				} else {
					this.userInfoService.updateUserInfoPassword(account, newPassword);
					result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.UPDATE_PASSWORD_SUCCESS.getMsg()), true);
				}
			} else {
				result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.OPERATION_TIME_TOO_LONG.getMsg()), false);
			}

		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.UPDATE_PASSWORD_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 获得第一次登录验证码
	 *
	 * @param request
	 * @param response
	 */
	@ResponseBody
	@RequestMapping(value = "/getLoginCode.json")
	@RequiredParams(names = { "phone" })
	public BaseResponseBody getLoginCode(HttpServletRequest request, HttpServletResponse response) {
		BaseResponseBody result = null;
		try {
			// 获取手机号
			String phone = this.getParameterString("phone", null);
			// 生成验证码
			Captcha captcha = ImageCodeUtil.getCaptcha();
			// 验证手机号格式
			if (phone.matches("^1(3|4|5|6|7|8|9)\\d{9}$")) {
				SMSConfig smsConfig = ConfigManager.getInstance().parseObject(SMSConfig.class);
				String code = captcha.getChallenge();
				String[] phoneNumberSet = { "+86" + phone };
				String[] templateParamSet = { code, "1" };
				String s = smsUtil.sendSms(smsConfig.getSecretId(), smsConfig.getSecretKey(), smsConfig.getSdkAppId(), smsConfig.getSignName(), smsConfig.getLoginTemPlateId(), phoneNumberSet, templateParamSet);
				request.getSession().setAttribute(WebappKeyConstants.LOGIN_SMS_CODE_KEY + phone, code);
				result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_SUCCESS.getMsg()), true);
			} else {
				result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.PHONE_ERROR.getMsg()), null);
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SEND_CODE_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 第一次登录验证验证码
	 *
	 * @param request
	 * @return
	 */
	@ResponseBody
	@RequestMapping("/loginVerificationCode.json")
	@RequiredParams(names = { "phone", "code" })
	public BaseResponseBody loginVerificationCode(HttpServletRequest request, HttpServletResponse response) {
		BaseResponseBody result = null;
		try {
			String phone = this.getParameterString("phone", null);
			String code = this.getParameterString("code", null);

			// 登录最大间隔时间
			LoginConfig loginConfig = ConfigManager.getInstance().parseObject(LoginConfig.class);
			// 验证码判定
			if (loginConfig.getIsVerificationCode() != null || StringUtils.endsWithIgnoreCase(code, (String) request.getSession().getAttribute(WebappKeyConstants.LOGIN_SMS_CODE_KEY + phone))) {
				UserInfo userInfo = (UserInfo) request.getSession().getAttribute("userInfo");
				String roleCode = (String) request.getSession().getAttribute("roleCode");
				if (userInfo != null) {
					// 获取客户端系统类型
					String clientSystemType = FilterSystemTypeUtil.getInstance().getClientSystemType(request, response);
					// 创建相关缓存
					String tokenValue = this.createCache(clientSystemType, userInfo, null);
					request.getSession().setAttribute("roleCode", roleCode);
					// 返回登录验证响应VO（供前端HTML写入Header等缓存）
					VerificationResponseVO responseVO = new VerificationResponseVO();
					// 获取公会审核状态
					TradeUnion tradeUnion = this.tradeUnionService.selectByUserId(userInfo.getId());
					if (tradeUnion != null) {
						responseVO.setStatus(tradeUnion.getAuditStatus());
						responseVO.setTradeUnion(tradeUnion);
					}
					responseVO.setSource(userInfo.getSourceSys());
					responseVO.setTokenCookieValue(tokenValue);
					result = new BaseResponseBody(true, CommonResponseCode.SUCCESS.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.SUCCESS.getMsg()), responseVO);
				} else {
					result = new BaseResponseBody(true, CommonResponseCode.FAILURE_AUTHENTICATION.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_ERROR.getMsg()), false);
				}
			} else {
				result = new BaseResponseBody(true, CommonResponseCode.FAILURE_AUTHENTICATION.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_ERROR.getMsg()), false);
			}
		} catch (Exception e) {
			logger.error(e.getMessage(), e);
			result = new BaseResponseBody(false, CommonResponseCode.ERROR.getCode(), this.getLocaleMessage(this.getClass(), RegisterResponseMsg.ACCOUNT_ERROR.getMsg()), e.getMessage(), null);
		}
		return result;
	}

	/**
	 * 创建相关缓存
	 *
	 * @param systemType
	 * @param userInfo
	 * @param tenantAppCodeList
	 * @return
	 * @throws Exception
	 */
	private String createCache(String systemType, UserInfo userInfo, List<Map<String, Object>> tenantAppCodeList) throws Exception {

		String roleName = userInfo.getRoleName();
		String roleCode = userInfo.getRoleCode();
		String roleId = userInfo.getRoleId();
		Integer isFirstLogin = userInfo.getIsFirstLogin();
		Integer isSameDayFirstLogin = userInfo.getIsSameDayFirstLogin();

		// 更新用户信息
		userInfo = this.userInfoService.updateLoginInfo(userInfo.getId(), AccessObjectUtil.getClientAddress());
		userInfo.setRoleName(roleName);
		userInfo.setRoleCode(roleCode);
		userInfo.setRoleId(roleId);
		userInfo.setIsFirstLogin(isFirstLogin);
		userInfo.setIsSameDayFirstLogin(isSameDayFirstLogin);

		// 获取角色信息
		List<Role> roleList = this.roleService.selectByUserId(userInfo.getId());

		// 获取权限信息
		List<Menu> permissionList = this.menuService.selectByUserId(userInfo.getId());

		// 创建相关缓存
		return FilterCacheUtil.createCache(systemType, userInfo.getAccount(), userInfo, roleList, permissionList, tenantAppCodeList, null, null, null);
	}
}
